home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000010_icon-group-sender _Wed Jul 2 23:33:27 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  1KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Tue, 8 Jul 1997 08:43:27 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA24479; Tue, 8 Jul 1997 08:43:26 -0700
  4. Message-Id: <3.0.1.32.19970702233327.007cad30@alterdial.uu.net>
  5. X-Sender: mail08621@alterdial.uu.net
  6. X-Mailer: Windows Eudora Pro Version 3.0.1 (32)
  7. Date: Wed, 02 Jul 1997 23:33:27 -0500
  8. To: icon-group@cs.arizona.edu
  9. From: Jerry Nowlin <nowlin@nowlin.com>
  10. Subject: Re: A small puzzle (never fails)
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset="us-ascii"
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14. Status: RO
  15.  
  16. >I couldn't resist.  I have an Icon solution:
  17. >
  18. >    # the longest common prefix procedure
  19. >    procedure lcp(a,b); return a ? tab(match(b[1:*b to 0 by -1])); end
  20.  
  21. Insufficient testing rigor.  If the original strings are identical the
  22. above loses the last character of the lcp.  Try this one:
  23.  
  24.     procedure lcp(a,b); return a ? tab(match(b[1:*b+1 to 1 by -1])); end
  25.  
  26. I have to remember Icon starts with 1, not 0 :-)  Sorry.
  27.  
  28. Jerry Nowlin
  29.  
  30.  
  31. Jerry Nowlin
  32. nowlin@nowlin.com
  33. http://www.xnet.com/~nowlin/
  34.